You are here: Trading System Programming > Reference > Classes > Account > Account Methods > placeMarketOrder

placeMarketOrder

The placeMarketOrder method places a market order inline without the need for creating a separate Order object.

Syntax

var placeMarketOrder(symbol, quantity, actionType, tifType);

Parameters

symbol

Symbol string for which to place the order.

 

quantity

Floating or numeric order quantity.

 

actionType

One of the order action types such as buy or sell.

 

tifType

One of the time-in-force types such as Day or Good-till-Canceled.

Return Value

This method returns true if order was placed successfully, false otherwise.

Example

The following example demonstrates the use of placeMarketOrder method.

 

function init()

{

//add "Default Trading Size" parameter

addParameter("Default Trading Size", "This is the default trading size volume", 1000);

}

 

function start()

{

//retrieve short positions for all symbols

var account = getAccount();

 

var placeLongOrder = false;

 

//determine whether a long order needs to be placed

..

..

..

 

if(placeLongOrder)

{

var rc = account.placeMarketOrder(getSymbol(),

parseFloat(getParameter("Default Trading Size")),

ACTIONTYPE_BUY,

TIFTYPE_DAY);

}

}

See Also

init(), start(), addParameter(), getParameter()

 


Copyright © 2006-2009 ActiveTick LLC